package com.my.cas.domain;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

/**
 * 用户信息
 */
@Data
public class UserInfo implements UserDetails {
    private static final long serialVersionUID = -1041327031937199938L;

    private String id;
    private String username;
    private String email;
    private String countryCode;
    private String mobile;
    private String nickname;
    private String role;
    private String realName;

    private String password;

    private boolean isAccountNonExpired = true; //是否过期

    private boolean isAccountNonLocked = true;//账户未锁定为true

    private boolean isCredentialsNonExpired = true;//证书不过期为true

    private boolean isEnabled = true;//是否可用

    private Set<AuthorityInfo> authorities = new HashSet<AuthorityInfo>();

//    @Override
//    public Collection<? extends GrantedAuthority> getAuthorities() {
//        if(this.getRole() == null || this.getRole().length() <1){
//            return AuthorityUtils.commaSeparatedStringToAuthorityList("");
//        }
//        else{
//            return AuthorityUtils.commaSeparatedStringToAuthorityList(this.getRole());
//        }
//    }


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

}